import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);

const routes=[
    //根路由重定向
    {
        path:'/',
        redirect:'/goods'
    },
    {
        path:'/goods',
        redirect:'/goods/list',
        component:()=>import('../views/goods/goods.vue'),
        children:[
            {
                path:'list',
                component:()=>import('../views/goods/children/goodsList.vue')
            },
            {
                path:'detail',
                component:()=>import('../views/goods/children/goodsDetail.vue')
            }
        ]
    },
    {
        path:'/type',
        component:()=>import('../views/goods/children/type.vue')
    },
    {
        path:'/cart',
        component:()=>import('../views/cart/cart.vue')
    },
    {
        path:'/my',
        redirect: "/my/center",
        component:()=>import('../views/my/my.vue'),
        children:[
            {
                path:'center',
                component:()=>import('../views/my/children/center.vue')
            },
            {
                path:'set',
                component:()=>import('../views/my/children/set.vue')
            }
        ]
    },
    {
        path:'/order',
        component:()=>import('../views/order/order.vue'),
        children:[
            {
                path:'list',
                component:()=>import('../views/order/children/orderList.vue')
            },
            {
                path:'detail',
                component:()=>import('../views/order/children/orderDetail.vue')
            }
        ]
    },
    {
        path:'/demo',
        component:()=>import('../views/demo/demo.vue')
    },
    {
        path:'/demo2/:class',
        name:'demo-detail',
        component:()=>import('../views/demo2/demo2.vue')
    },
    {
        path:'*',
        component:()=>import('@/components/NotFound')
    }
]

const router = new Router({
    mode:'history',
    routes
})

export default router